package caiziyou.com.designpattern.singleton.type2;

/**
 * 单例模式 饿汉式 静态代码块
 * 
 * @author Administrator
 *
 */
public class Singleton {

	public static void main(String[] args) {
		Singleton instance1 = Singleton.getInstance();
		Singleton instance2 = Singleton.getInstance();
		System.out.println(instance1 == instance2);
	}

	private Singleton() {
	}

	private static Singleton instance;

	static {
		instance = new Singleton();
	}

	public static Singleton getInstance() {
		return instance;
	}

}
